package cn.qidd.keep.order.model.order;

import cn.qidd.keep.domain.core.dict.PayChannel;
import cn.qidd.keep.domain.core.dict.PayType;
import cn.qidd.keep.domain.core.dict.WhetherStatus;
import cn.qidd.keep.domain.document.Product;
import cn.qidd.keep.domain.web.BusinessException;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@Data
public class CreateOrderRequest {
    @ApiModelProperty("客户名称/会员名称")
    private String name;
    @ApiModelProperty("手机号码/会员手机号")
    private String phone;
    @ApiModelProperty("订单消费金额")
    private Double amount;
    @ApiModelProperty("支付方式")
    @NotNull(message = "支付方式不能为空")
    private PayType payType;
    @ApiModelProperty("支付通道")
    @NotNull(message = "支付通道不能为空")
    private PayChannel payChannel;
    @ApiModelProperty("是否使用会员")
    private WhetherStatus isMember;
    @ApiModelProperty("会员编号")
    private String memberNo;
    @ApiModelProperty("美发师用户名/工号")
    @NotBlank(message = "美发师工号不能为空")
    private String hairdresserUserName;
    @ApiModelProperty("美发师名")
    @NotBlank(message = "美发师名不能为空")
    private String hairdresserName;
    @ApiModelProperty("部门CODE")
    private String deptCode;
    @ApiModelProperty("部门名称")
    private String deptName;

    public void valid() {
        if (isMember.equals(WhetherStatus.YES)) {
            if (StringUtils.isBlank(memberNo)) {
                throw new BusinessException("会员编号不能为空");
            }
            if (StringUtils.isBlank(name)) {
                throw new BusinessException("客户名称不能为空");
            }
            if (StringUtils.isBlank(phone)) {
                throw new BusinessException("手机号不能为空");
            }
        } else {
            if (amount == null) {
                throw new BusinessException("消费金额不能为空");
            }
        }
    }
}
